home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / Quill / Source / ListBoxEditor.cpp < prev    next >
Text File  |  1997-08-11  |  4KB  |  152 lines

  1. /*
  2.  *  File:       ListBoxEditor.cpp
  3.  *  Summary:       A view that knows how to edit a TListBox.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1997 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <->     1/22/97    JDJ        Created
  12.  */
  13.  
  14. #include "ListBoxEditor.h"
  15.  
  16. #include <ZColorSwatch.h>
  17. #include <ZControl.h>
  18.  
  19.  
  20. // ===================================================================================
  21. //    class CEditListBoxCommand
  22. // ===================================================================================
  23.  
  24. //---------------------------------------------------------------
  25. //
  26. // CEditListBoxCommand::~CEditListBoxCommand
  27. //
  28. //---------------------------------------------------------------
  29. CEditListBoxCommand::~CEditListBoxCommand()
  30. {
  31. }
  32.  
  33.  
  34. //---------------------------------------------------------------
  35. //
  36. // CEditListBoxCommand::CEditListBoxCommand
  37. //
  38. //---------------------------------------------------------------
  39. CEditListBoxCommand::CEditListBoxCommand(TListBoxBase* pane, const SListBoxInfo& oldInfo, const SListBoxInfo& newInfo) : Inherited(pane, oldInfo, newInfo)
  40. {
  41. }
  42.  
  43.  
  44. //---------------------------------------------------------------
  45. //
  46. // CEditListBoxCommand::UpdatePane
  47. //
  48. //---------------------------------------------------------------
  49. void CEditListBoxCommand::UpdatePane(const SListBoxInfo& inInfo)
  50. {
  51.     SListBoxInfo info = inInfo;
  52.     
  53.     mPane->SetInfo(info);
  54. }
  55.  
  56. #pragma mark -
  57.  
  58. // ===================================================================================
  59. //    CListBoxEditor
  60. // ===================================================================================
  61.  
  62. static TReanimatorRegister<CListBoxEditor> sListBoxEditorRegistrar;
  63.  
  64. //---------------------------------------------------------------
  65. //
  66. // CListBoxEditor::~CListBoxEditor
  67. //
  68. //---------------------------------------------------------------
  69. CListBoxEditor::~CListBoxEditor()
  70. {
  71. }
  72.  
  73.  
  74. //---------------------------------------------------------------
  75. //
  76. // CListBoxEditor::CListBoxEditor
  77. //
  78. //---------------------------------------------------------------
  79. CListBoxEditor::CListBoxEditor(TView* superView) : Inherited(superView)
  80. {
  81. }
  82.  
  83.  
  84. //---------------------------------------------------------------
  85. //
  86. // CListBoxEditor::Create                                [static]
  87. //
  88. //---------------------------------------------------------------
  89. MReanimatable* CListBoxEditor::Create(MReanimatable* parent)
  90. {
  91.     return new CListBoxEditor(dynamic_cast<TView*>(parent));
  92. }
  93.  
  94.  
  95. //---------------------------------------------------------------
  96. //
  97. // CListBoxEditor::GetEditorInfo        
  98. //
  99. //---------------------------------------------------------------
  100. SListBoxInfo CListBoxEditor::GetEditorInfo() const
  101. {
  102.     SListBoxInfo info;
  103.     
  104.     TControl* control = nil;
  105.         
  106.     control = dynamic_cast<TControl*>(this->FindSubPane("Can Scroll"));
  107.     info.canScroll = control->GetValue();
  108.     
  109.     control = dynamic_cast<TControl*>(this->FindSubPane("Allow Multiple Selections"));
  110.     info.allowMultipleSelections = control->GetValue();
  111.     
  112.     control = dynamic_cast<TControl*>(this->FindSubPane("Draw Focus Box"));
  113.     info.drawFocusBox = control->GetValue();
  114.     
  115.     control = dynamic_cast<TControl*>(this->FindSubPane("Draw Frame"));
  116.     info.framePixels = control->GetValue();
  117.     
  118.     TColorSwatch* swatch = dynamic_cast<TColorSwatch*>(this->FindSubPane("Back Color"));
  119.     info.backColor = swatch->GetColor();
  120.     
  121.     return info;
  122. }
  123.  
  124.  
  125. //---------------------------------------------------------------
  126. //
  127. // CListBoxEditor::SetEditorInfo
  128. //
  129. //---------------------------------------------------------------
  130. void CListBoxEditor::SetEditorInfo(const SListBoxInfo& info)
  131. {
  132.     TControl* control = nil;
  133.     
  134.     control = dynamic_cast<TControl*>(this->FindSubPane("Can Scroll"));
  135.     control->SetValue(info.canScroll);
  136.     
  137.     control = dynamic_cast<TControl*>(this->FindSubPane("Allow Multiple Selections"));
  138.     control->SetValue(info.allowMultipleSelections);
  139.     
  140.     control = dynamic_cast<TControl*>(this->FindSubPane("Draw Focus Box"));
  141.     control->SetValue(info.drawFocusBox);
  142.  
  143.     control = dynamic_cast<TControl*>(this->FindSubPane("Draw Frame"));
  144.     control->SetValue(info.framePixels > 0);
  145.     
  146.     TColorSwatch* swatch = dynamic_cast<TColorSwatch*>(this->FindSubPane("Back Color"));
  147.     swatch->SetColor(info.backColor);
  148. }
  149.  
  150.  
  151.  
  152.